package com.ljy.controller.user;

import com.ljy.dto.LeasePageDTO;
import com.ljy.entity.Lease;
import com.ljy.entity.RollImage;
import com.ljy.result.PageResult;
import com.ljy.result.Result;
import com.ljy.service.LeaseService;
import com.ljy.vo.LeaseVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController("userLeaseController")
@RequestMapping("/user/lease")
public class LeaseController {
    @Autowired
    LeaseService leaseService;
    @GetMapping("/page")
    public Result<PageResult<LeaseVO>> pageSelect(LeasePageDTO dto){
        PageResult<LeaseVO> pageResult= leaseService.selectPage(dto);
        return Result.success(pageResult);

    }
    @GetMapping("/{id}")
    public Result<Lease> selectById(@PathVariable Integer id){
        Lease lease = leaseService.selectById(id);
        return Result.success(lease);
    }
    @GetMapping("/rollImage")
    public Result<List<RollImage>> selectRollImage(){
        List<RollImage> images=leaseService.getRollImage();
        return Result.success(images);
    }
}
